<?php
namespace gzapi\common\model;
use think\Model;
class GzHiseServiceInspectionModel extends Model{
     public static  $Instance;
    protected $autoWriteTimestamp = true;

     public function _initialize(){
     }
     public static  function Instance(){
         if(!self::$Instance){
             self::$Instance=new self();
         }
         return self::$Instance;
     }
    /*获取多个*/
    public static function getInspection($array){
        $res=self::Instance()->where($array)->select();
        return $res;
    }
    //更改数据
    public static function updateInspection($where,$data){

        $res=self::Instance()->where($where)->update($data);
        return $res;
    }
    //保存巡检单
    public static function createInspection($data){
        $res=self::Instance()->insert($data);
        return $res;
    }
    //条件查找数量
   public function inspectListNumIng($where,$azdwhere=[]){
//        $res=$this->where($where)->group('xj_azdbh')->count();
//        return $res;
       $res=$this->alias('a')
           ->join('cmf_gz_hise_service_project w','a.xj_azdbh = w.azd_id')
           ->where($where)
           ->where($azdwhere)
           ->group('a.xj_azdbh')->count();
       return $res;
   }
   //分组查询总数
    public  function  inspectNumCount($where){
        $res=$this->where($where)->field('xj_azdbh,count(*) as xj_total')->group('xj_azdbh')->select();
        return $res;
    }
    public function inspectAzdNum($where){
        $res=$this->where($where)->group('xj_azdbh')->count();
        return $res;
    }
    public function azdIdArr($where){
        $res=$this->where($where)->column('xj_azdbh');
        return $res;
   }
}